package dataMapper;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class MapIndexMapper {
	public static  Map<String,Map<String,Integer>> process(BufferedReader br){
		Map<String,Map<String,Integer>> map = new HashMap<String,Map<String,Integer>> ();
		try {
			br.readLine();
			while(br.ready()){
				String[] object = buildObject(br.readLine());

				Map<String,Integer> stateMap = map.get(object[0]);
				if(stateMap == null) stateMap = new HashMap<String,Integer>();
				stateMap.put(object[1], Integer.valueOf(object[2]));
				map.put(object[0], stateMap);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return map;
	}
	
	public static String[] buildObject(String inLine){
		String[] input = inLine.split("\t");
		String[] inches = input[1].split(",");
		String[] object = new String[3];
		object[0] = inches[1].trim();
		object[1] = inches[0].trim();
		object[2] = input[0].trim();
		return object;
	}

}
